package leetcode_2301_2400;

import java.util.Arrays;

public class LeeCode_2305 {
    public static void main(String[] args) {

    }
    private static int distributeCookies(int[] cookies, int k) {
        int n = cookies.length;
        int[] sums = new int[1 << n];
        for (int i = 0; i < n; i++) {
            for(int j = 0, bit = 1 << i; j < bit ;j++){
                sums[bit | j] = sums[j] + cookies[i];
            }
        }
        int[] f = sums.clone();
        for (int i = 1; i < k; i++) {
            for(int j = (1 << n) - 1; j > 0; j--){
                for(int s = j; s > 0; s = (s - 1) & j){
                    f[j] = Math.min(f[j], Math.max(f[s], sums[s ^ j]));
                }
            }
        }
        return f[(1 << n) - 1];
    }
}